package ru.cybertek.domain;

import ru.cybertek.domain.constant.AccountType;
import ru.cybertek.domain.Company;
import ru.cybertek.domain.Person;
import ru.cybertek.domain.Account;


public class PayerImpl implements Payer 
{
	private Account account;
	
	public PayerImpl() {};
	
	public PayerImpl(Account account)
	{
		this.account = account;
	}
	
	/*
	 * (non-Javadoc)
	 * @see ru.cybertek.financial.document.Payer#getName()
	 */
	public String getName()
	{
		String name = null;

        if (account.getAccountType() == AccountType.PERSONAL)
        {
            Person owner = (Person) account.getOwner();
            //name = owner.getFullName();
            name = owner.getFirstName()+" "+owner.getLastName();
        } else if (account.getAccountType() == AccountType.CORPORATE)
        {
            Company owner = (Company) account.getOwner();
            name = owner.getShortName();
        }

        return name;		
	}
	
	/*
	 * (non-Javadoc)
	 * @see ru.cybertek.financial.document.Payer#getInn()
	 */
	public String getInn()
	{
		String inn = null;

        if (account.getAccountType() == AccountType.PERSONAL)
        {
            Person owner = (Person) account.getOwner();
            inn = owner.getFinancialDetails().getInn();
        } else if (account.getAccountType() == AccountType.CORPORATE)
        {
            Company owner = (Company) account.getOwner();
            inn = owner.getFinancialDetails().getInn();
        }

        return inn;
	}
	
	/*
	 * (non-Javadoc)
	 * @see ru.cybertek.financial.document.Payer#getKpp()
	 */
	public String getKpp()
	{
		 String kpp = null;

        if (account.getAccountType() == AccountType.CORPORATE)
        {
            Company owner = (Company) account.getOwner();
            kpp = owner.getFinancialDetails().getKpp();
        }

        return kpp;
	}
	
	/*
	 * (non-Javadoc)
	 * @see ru.cybertek.financial.document.Payer#getAccountNumber()
	 */
	public String getAccountNumber()
	{
		return account.getAccountNumber();
	}
	
	/*
	 * (non-Javadoc)
	 * @see ru.cybertek.financial.document.Payer#getBankAccountNumber()
	 */
	public String getBankAccountNumber()
	{
		return account.getBank().getCurrentAccount();
	}
	
	/*
	 * (non-Javadoc)
	 * @see ru.cybertek.financial.document.Payer#getBankName()
	 */
	public String getBankName()
	{
		return account.getBank().getShortName();
	}
	
	/*
	 * (non-Javadoc)
	 * @see ru.cybertek.domain.Payer#getBankBic()
	 */
	public String getBankBic()
	{
		return account.getBank().getBic();
	}
	
	/*
	 * (non-Javadoc)
	 * @see ru.cybertek.domain.Payer#getAccountId()
	 */
	public Integer getAccountId()
	{
		return account.getId();
	}
}
